package com.springcloud.springcloudclient01.com.ded;

import java.util.HashMap;
import java.util.Map;

/**
 * Describle:
 * ClassName: ThreadLocalUtil
 * Author: duende
 * DateTime: 2021/7/10 9:34
 */
public final class ThreadLocalUtil {

    protected static ThreadLocal<Map<String, Object>> threadlocal = ThreadLocal.withInitial(() -> {
        return new HashMap<>();
    });

    public static void set(String key, Object value) {
        threadlocal.get().put(key, value);
    }

    public static Object get(String key) {
        return threadlocal.get().get(key);
    }

    public static void remove() {
        threadlocal.remove();
    }

}
